home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / VISUALBA / VBSETUPK.ZIP / SETUP1.FRM < prev    next >
Text File  |  1993-10-14  |  15KB  |  414 lines

  1. VERSION 2.00
  2. Begin Form Setup1 
  3.    BackColor       =   &H00400000&
  4.    Caption         =   "Test App Setup"
  5.    ClientHeight    =   2130
  6.    ClientLeft      =   1860
  7.    ClientTop       =   2610
  8.    ClientWidth     =   5640
  9.    ControlBox      =   0   'False
  10.    FillStyle       =   0  'Solid
  11.    FontBold        =   -1  'True
  12.    FontItalic      =   -1  'True
  13.    FontName        =   "MS Sans Serif"
  14.    FontSize        =   24
  15.    FontStrikethru  =   0   'False
  16.    FontUnderline   =   0   'False
  17.    ForeColor       =   &H00000000&
  18.    Height          =   2535
  19.    Icon            =   SETUP1.FRX:0000
  20.    Left            =   1800
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form3"
  23.    MaxButton       =   0   'False
  24.    MinButton       =   0   'False
  25.    ScaleHeight     =   142
  26.    ScaleMode       =   3  'Pixel
  27.    ScaleWidth      =   376
  28.    Top             =   2265
  29.    Width           =   5760
  30.    Begin Label Label2 
  31.       BorderStyle     =   1  'Fixed Single
  32.       Caption         =   "To customize this setup program, modify the FORM_LOAD event procedure in this form."
  33.       Height          =   435
  34.       Left            =   15
  35.       TabIndex        =   1
  36.       Top             =   15
  37.       Visible         =   0   'False
  38.       Width           =   5625
  39.    End
  40.    Begin Label Label1 
  41.       BorderStyle     =   1  'Fixed Single
  42.       Caption         =   "This label used for DDE connection to the Program Manager"
  43.       Height          =   390
  44.       Left            =   15
  45.       TabIndex        =   0
  46.       Top             =   525
  47.       Visible         =   0   'False
  48.       Width           =   5610
  49.    End
  50. End
  51.  
  52. 'Version = 1.00.002
  53.  
  54. Const APPNAME = "Loan Application"
  55. Const APPDIR = "C:\LOAN"    ' The default install directory
  56. Const fDataAccess% = False
  57. Const fODBC% = False
  58. Const fBtrieve% = False
  59. Const fOLE2% = False
  60.  
  61. ' Set the total uncompressed file sizes
  62. ' by adding the sizes of the files
  63. Const WINSYSNEEDED = 40896  ' Files that go into WINDOWS and SYSTEM directory
  64. Const OTHERNEEDED = 12555   ' Files that don't go into the WINDOWS or SYSTEM directory
  65.  
  66. Sub DrawBackground ()
  67.     Setup1.CurrentY = 5
  68.     Setup1.CurrentX = 5
  69.     Setup1.ForeColor = QBColor(15)
  70.     Print APPNAME + " Setup"
  71. End Sub
  72.  
  73. Sub Form_Load ()
  74.     
  75.     '----------
  76.     ' Initialize
  77.     '----------
  78.     dialogCaption$ = APPNAME + " Setup"
  79.     ShowMainForm dialogCaption$
  80.  
  81.     winDrive$ = UCase$(Left$(winDir$, 1))
  82.     winDir$ = UCase$(GetWindowsDir$())
  83.     winSysDir$ = UCase$(GetWindowsSysDir$())
  84.     
  85.     '----------------------------------------------------
  86.     ' Get Window version
  87.     '----------------------------------------------------
  88.     TheVerInfo& = GetVersion()
  89.     WinVer& = TheVerInfo& And &HFFFF&
  90.     If Val(Format$(WinVer& Mod 256) + "." + Format$(WinVer& \ 256)) >= 3.1 Then
  91.         gfWin31% = True
  92.     End If
  93.     
  94.     '----------------------------------------------------
  95.     ' OLE 2.0 requires Win 3.1 or greater
  96.     '----------------------------------------------------
  97.     If fOLE2% And Not gfWin31% Then
  98.         MsgBox "This application requires Windows 3.1 or later"
  99.         GoTo ErrorSetup
  100.     End If
  101.  
  102.     '----------------------------------------------------
  103.     ' SETUP.EXE passes the source drive in a command
  104.     ' argument.  If it is empty,  that means the user
  105.     ' executed this .exe directly.  In that case, show
  106.     ' a dialog to get the desired source directory.
  107.     '----------------------------------------------------
  108.     SourcePath$ = Command$
  109.     If SourcePath$ = "" Then
  110.         title$ = dialogCaption$
  111.         caption1$ = "Please enter the drive or path containing the " + APPNAME + " source files."
  112.         caption2$ = "Install From:"
  113.         defaultDrive$ = "A:"
  114.         defaultText$ = "A:\"
  115.  
  116.         ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, SourcePath$, outButton$
  117.  
  118.         If outButton$ = "exit" Then GoTo ErrorSetup
  119.     Else
  120.         If Right$(SourcePath$, 1) <> "\" Then
  121.             SourcePath$ = SourcePath$ + "\"
  122.         End If
  123.     End If
  124.  
  125.  
  126.     '--------------------
  127.     ' Get Destination Path
  128.     '--------------------
  129.     title$ = dialogCaption$
  130.     caption1$ = "If you want to install the " & APPNAME & " in a different directory and/or drive, type the name of the directory."
  131.     caption2$ = "Install To:"
  132.     defaultDrive$ = "C:"
  133.     defaultText$ = APPDIR
  134.  
  135.     ShowPathDialog title$, caption1$, caption2$, defaultDrive$, defaultText$, destPath$, outButton$
  136.  
  137.     If outButton$ = "exit" Then GoTo ErrorSetup
  138.     
  139.     '-----------------------------------------
  140.     ' Dim disk space variables as Long Integers
  141.     '-----------------------------------------
  142.     Dim winSpaceFree As Long
  143.     Dim sourceSpaceFree As Long
  144.     Dim destSpaceFree As Long
  145.     Dim totalNeeded As Long
  146.  
  147.     '---------------------------------------------------------
  148.     ' If the Windows \SYSTEM directory is a subdirectory
  149.     ' of the Windows directory, the proper place for
  150.     ' installation of .VBXs and shared .DLLs is the
  151.     ' Windows \SYSTEM directory.
  152.     '
  153.     ' If the Windows \SYSTEM directory is *not* a subdirectory
  154.     ' of the Windows directory, then the user is running a
  155.     ' shared version of Windows, and the proper place for
  156.     ' installation of .VBXs and shared .DLLs is the
  157.     ' Windows directory.
  158.     '---------------------------------------------------------
  159.     If InStr(winSysDir$, winDir$) = 0 Then
  160.         winSysDir$ = winDir$
  161.     End If
  162.  
  163.     
  164.     '---------------------------------
  165.     ' Get Drive Letters of directories
  166.     '---------------------------------
  167.     destDrive$ = UCase$(Left$(destPath$, 1))
  168.     sourceDrive$ = UCase$(Left$(SourcePath$, 1))
  169.  
  170.     '---------------------------------
  171.     ' Compute free disk space variables
  172.     '---------------------------------
  173.     winSpaceFree = GetDiskSpaceFree(winDrive$)
  174.     destSpaceFree = GetDiskSpaceFree(destDrive$)
  175.     
  176.     '-----------------------------------------
  177.     ' Check for enough disk space.
  178.     '
  179.     ' Some components are being installed into the
  180.     ' Windows\SYSTEM directory.
  181.     '
  182.     ' So if the main destination path is on a
  183.     ' different drive than the drive with
  184.     ' the Windows \SYSTEM directory, we have to
  185.     ' check both drives.
  186.     '
  187.     ' An example of this is when the user is installing
  188.     ' the main product to drive D:, but the Windows
  189.     ' directory is on drive c:
  190.     ' -----------------------------------------
  191.     totalNeeded = WINSYSNEEDED + OTHERNEEDED
  192.     
  193.     If winDrive$ = destDrive$ Then
  194.         If destSpaceFree < totalNeeded Then
  195.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":   An estimated" + Str$(totalNeeded - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  196.             GoTo ErrorSetup
  197.         End If
  198.     Else
  199.         If winSpaceFree < WINSYSNEEDED Then
  200.             MsgBox "There is not enough disk space on drive " + winDrive$ + ":  An estimated" + Str$(WINSYSNEEDED - winSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  201.             GoTo ErrorSetup
  202.         End If
  203.         If destSpaceFree < OTHERNEEDED Then
  204.             MsgBox "There is not enough disk space on drive " + destDrive$ + ":  An estimated" + Str$(OTHERNEEDED - destSpaceFree) + " additional bytes are needed.", 16, dialogCaption$
  205.             GoTo ErrorSetup
  206.         End If
  207.         
  208.     End If
  209.  
  210.     '----------------------------
  211.     ' Create destination directory
  212.     '----------------------------
  213.     If Not CreatePath(destPath$) Then GoTo ErrorSetup
  214.     
  215.  
  216.     '-----------------------------------------------------------
  217.     ' Show Status Dialog -- This stays up while copying files
  218.     ' It is required by the CopyFile routine
  219.     '-----------------------------------------------------------
  220.     ShowStatusDialog dialogCaption$, totalNeeded
  221.     
  222.     
  223.     '-----------
  224.     ' Copy Files
  225.     '-----------
  226.  
  227.     ' Test to see if loan.exe is on the disk, if not then you know the user
  228.     ' did not insert the first disk
  229.     If Not PromptForNextDisk(1, SourceP